package de.hwrberlin.remo.algorithm.steps;

import de.hwrberlin.expertsystem.util.ModelEditingHelper;
import de.hwrberlin.remo.algorithm.UserInterface;
import de.hwrberlin.remo.model.Rule;

/**
 * Algorithm step, which validates the state of a rule.
 * 
 * @author Mario S��nger (IT 09)
 * @version 1.0
 *
 */
public class ValidateRuleStep implements AlgorithmStep {

	private Rule rule;
	private UserInterface userInterface;
	private ModelEditingHelper helper;
	
	public ValidateRuleStep(Rule rule, UserInterface userInterface, ModelEditingHelper helper) {
		this.rule = rule;
		this.userInterface = userInterface;
		this.helper = helper;
	}

	@Override
	public String getLabel() {
		return "Validating rule " + rule.getName();
	}

	@Override
	public void perform() {
		helper.setRuleValidated(rule, true);
		userInterface.highlightElement(rule);
	}

	@Override
	public void revert() {
		helper.setRuleValidated(rule, false);
		userInterface.unhighlightElement(rule);
	}

	@Override
	public String getExplanation() {
		return "Validate rule " + rule.getName() + 
				" to decide whether the state is true, false or unknown.";
	}
}